global root "/Volumes/Workgroup/Lab/Lab-heimb/Montenovo/Volunteering Paper/Data"
global results "$root/07_results/RR/main"
global dictionaries "$root/Dictionaries"

cd "$dictionaries"
capture log close
log using preliminary_regressions_gender_mstatus, replace


cd "$root"


use appended_analytic_010305111719, clear 

// I am a single male if I am not married, I am a male, and I am the head
//generate single_male=0
//replace single_male=1 if head_married==0 & sex==1 & sequence_num==1

// I am a single female if I am not married, I am a female, and I am the head
//generate single_female=0
//replace single_female=1 if head_married==0 & sex==2 & sequence_num==1

//generate married_male=0
//replace married_male=1 if head_married==1 & sex==1 
//replace married_male=1 if head_married==1 & sex_spouse==1

//generate married_female=0
//replace married_female=1 if head_married==1 & sex==2

//tab single_male // 12,863
//tab single_female // 17,995
//tab married_male // 28,383
//tab married_female // 28,371



// single male

eststo extensive_margin_sm: reghdfe whether_volunteer_person taxprice post_tax_income hourly_wage_aftertax full_time  age black native_amer asian other hispanic HS some_college college_grad college_plus children  religion rural if (sex==1 & sequence_num==1 & married==0), absorb(year state unique_id_crossys) vce(cluster state)

sum whether_volunteer_person if sex==1 & sequence_num==1 & married==0

gen sample=e(sample)
bysort unique_id_crossys: gen nvals=_n==1
count if nvals==1 & sample==1
drop sample nvals


/*
//(dropped 3794 singleton observations)
 gen c=1
bysort family_id state: egen sum_singlemale=sum(c) if single_male==1
tab sum_singlemale

/* tab sum_singlemale

     sum_cc |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |      3,751       35.91       35.91
          2 |      4,116       39.40       75.31
          3 |      2,037       19.50       94.81
          4 |        476        4.56       99.37
          5 |         60        0.57       99.94
          6 |          6        0.06      100.00
------------+-----------------------------------
      Total |     10,446      100.00
*/

foreach var of varlist Hyear taxprice post_tax_income page black_h native_amer_h asian_h other_h hispanic_head HS_h some_college_h college_grad_h college_plus_h children {
	count if `var'==. & single_male==1
}

/* 
  127
  108
  0
  0
  0
  0
  0
  0
  367
  0
  0
  0
  0
  0
*/	

*/

*extensive, year state family fe - single female
eststo extensive_margin_sf: reghdfe whether_volunteer_person taxprice post_tax_income hourly_wage_aftertax full_time  age    black native_amer asian other hispanic HS some_college college_grad college_plus children  religion rural if (sex==2 & sequence_num==1 & married==0), absorb(year state unique_id_crossys) vce(cluster state)
// (dropped 3327 singleton observations)

gen extensive_margin_sf=e(sample)
sum whether_volunteer_person if sex==2 & sequence_num==1 & married==0

gen sample=e(sample)
bysort unique_id_crossys: gen nvals=_n==1
count if nvals==1 & sample==1
drop sample nvals


//bysort family_id year state: egen sum_singlefemale=sum(c) if single_female==1
//tab sum_singlefemale

*extensive, year state family fe - married male
eststo extensive_margin_mm: reghdfe whether_volunteer_person taxprice post_tax_income hourly_wage_aftertax full_time  age    black native_amer asian other hispanic HS some_college college_grad college_plus children  religion rural if (sex==1 & married==1), absorb(year state unique_id_crossys) vce(cluster state)
// (dropped 2049 singleton observations)

gen sample=e(sample)
bysort unique_id_crossys: gen nvals=_n==1
count if nvals==1 & sample==1
drop sample nvals


//bysort family_id year state: egen sum_marriedmale=sum(c) if married_male==1
//tab sum_marriedmale

*extensive, year state family fe - married female
eststo extensive_margin_mf: reghdfe whether_volunteer_person taxprice post_tax_income hourly_wage_aftertax full_time  age    black native_amer asian other hispanic HS some_college college_grad college_plus children religion rural if (sex==2 & married==1), absorb(year state unique_id_crossys) vce(cluster state)
// (dropped 2067 singleton observations)

gen sample=e(sample)
bysort unique_id_crossys: gen nvals=_n==1
count if nvals==1 & sample==1
drop sample nvals


drop if year==2010
drop if hours_volunteer_person==0

*intensive, year state family fe - single male
eststo intensive_margin_sm: reghdfe hours_volunteer_person taxprice post_tax_income hourly_wage_aftertax full_time   age    black native_amer asian other hispanic HS some_college college_grad college_plus children   religion rural if (sex==1 & sequence_num==1 & married==0), absorb(year state unique_id_crossys) vce(cluster state)

gen sample=e(sample)
bysort unique_id_crossys: gen nvals=_n==1
count if nvals==1 & sample==1
drop sample nvals


*intensive, year state family fe - single female
eststo intensive_margin_sf: reghdfe hours_volunteer_person taxprice post_tax_income hourly_wage_aftertax full_time  age    black native_amer asian other hispanic HS some_college college_grad college_plus children  religion rural if (sex==2 & sequence_num==1 & married==0), absorb(year state unique_id_crossys) vce(cluster state)

gen sample=e(sample)
bysort unique_id_crossys: gen nvals=_n==1
count if nvals==1 & sample==1
drop sample nvals


*intensive, year state family fe - married male
eststo intensive_margin_mm: reghdfe hours_volunteer_person taxprice post_tax_income hourly_wage_aftertax full_time  age    black native_amer asian other hispanic HS some_college college_grad college_plus children  religion rural if (sex==1 & married==1), absorb(year state unique_id_crossys) vce(cluster state)

gen sample=e(sample)
bysort unique_id_crossys: gen nvals=_n==1
count if nvals==1 & sample==1
drop sample nvals


*intensive, year state family fe - married female
eststo intensive_margin_mf: reghdfe hours_volunteer_person taxprice  post_tax_income hourly_wage_aftertax full_time  age    black native_amer asian other hispanic HS some_college college_grad college_plus children  religion rural if (sex==2 & married==1), absorb(year state unique_id_crossys) vce(cluster state)

gen sample=e(sample)
bysort unique_id_crossys: gen nvals=_n==1
count if nvals==1 & sample==1
drop sample nvals


cd "$results"

	 esttab extensive_margin_sm extensive_margin_sf extensive_margin_mm extensive_margin_mf using "regress_extensive_gender_mstat.rtf", se star(* 0.10 ** 0.05 *** 0.01) replace se(a4) b(a3) title("Extensive Margin for Single Male, Single Female, Married Male and Married Female") addnotes("Col 1: Single Male" "Col 2: Single Female" "Col 3: Married Male" "Col 4: Married Female" "All Models include Year, State, and Individual FE") modelwidth(12) label cells(b(star fmt(3)) se(par fmt(3)))
	 
	 esttab intensive_margin_sm intensive_margin_sf intensive_margin_mm intensive_margin_mf using "regress_intensive_gender_mstat.rtf", se star(* 0.10 ** 0.05 *** 0.01) replace se(a4) b(a3) title("Intensive Margin for Single Male, Single Female, Married Male and Married Female") addnotes("Col 1: Single Male" "Col 2: Single Female" "Col 3: Married Male" "Col 4: Married Female" "All Models include Year, State, and Individual FE") modelwidth(12) label cells(b(star fmt(3)) se(par fmt(3)))

	 cd "$dictionaries"
	 
	 log close
